import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";
import { request } from "http";

export type userData = {
  Id?: number;
  username?: string;
  fullName?: string;
  Username?: string,
  Nickname?: string,
  FirstName?: string,
  Email?: string,
  Mobile?: number,
  Tel?: number,
  PDAId?: string,
  Status?: number,
  roleIds?: Array<number>,
  Note?: string,
};

type userSearch = {
  username?: string,
  UserName?: string;
  fullName: string,
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

// 用户列表
export const userList = (params?: userSearch) => {
  return http.request<Result>("get", "/api/User/List", { params });
};

// 新增用户
export const addUser = (data?: userData) => {
  return http.request<Result>("post", "/api/User/Add", { data });
};

// 修改用户
export const updateUser = (data?: userData) => {
  return http.request<Result>("post", `/api/User/Update/${data.Id}`, { data });
};

// 删除用户
export const delUser = (Id: number) => {
  return http.request<Result>("post", `/api/User/Delete/${Id}`, {});
};

// 用户select
export const GetUserByStatus = () => {
  return http.request<arrayResult>("get", "/api/User/GetUserByStatus", {});
};
